<?php
namespace app\admin\command;

use think\console\Command;
use think\console\Input;
use think\console\Output;
use app\common\service\NoticeService;
use app\common\service\MsgService;

class Msg extends Command {

    protected function configure() {
        $this->setName('msg')->setDescription('发送消息');
    }

    protected function execute(Input $input, Output $output) {
//         $this->sendLevelChangeMsg();
//         $this->sendRegSuccessMsg();
//         $this->sendRegFailMsg();
//         $this->sendRechargeSuccessMsg();
        $this->sendOrderSendMsg();
    }

    private function sendRegSuccessMsg() {
        $name = '王金喜';
        $money = 100;

        $data = [
            'openid' => 'oYj2y0UqPrYvsTkl1KtYmXBYceXI',
            'name' => $name,
            'first' => sprintf("尊敬的%s：您好！恭喜您成功注册成为品正商。", $name),
            'remark' => sprintf('您的登陆账号为注册手机号，密码默认为手机号后六位。请您牢记您的用户名与密码，并于首次登陆后尽快修改您的初始密码。首次充值的%s元货款将在1小时内到账。前去登陆', $money),
            'url' => 'http://yiqituan.test.mlilife.com/mobile/index/login.html'
        ];

        NoticeService::sendRegSuccessMsg($data);
    }

    private function sendRegFailMsg() {
        $fid = 1;
        $data = [
            'openid' => 'oYj2y0UqPrYvsTkl1KtYmXBYceXI',
            'time' => date('Y-m-d H:i:s'),
            'first' => '对不起，您的注册申请被驳回。',
            'remark' => '请在确认打款金额正确，且上传的支付截图正确清晰后，重新提交注册申请',
            'url' => sprintf('http://yiqituan.test.mlilife.com/mobile/index/register.html?fid=%d', $fid)
        ];

        NoticeService::sendRegFailMsg($data);
    }

    private function sendRechargeSuccessMsg() {
        // 充值成功通知：充值成功，您本次的充值金额为XXXXX.XX元！本次充值申请时间：2018.01.01 12:00:00，到账时间：2018.01.01 12:10:00
        $money = 100;
        $account = 200;
        $addTime = date('Y.m.d H:i:s');
        $endTime = date('Y.m.d H:i:s');
        $data = [
            'openid' => 'oYj2y0UqPrYvsTkl1KtYmXBYceXI',
            'first' => sprintf('充值成功,您本次的充值金额为%s元！',$money),
            'money'=>$money,
            'time' => date('Y.m.d H:i:s'),
            'account'=> $account,
            'remark' => sprintf('本次充值申请时间：%s，到账时间：%s',$addTime,$endTime),
            'url' => 'http://yiqituan.test.mlilife.com/mobile/index/assets.html'
        ];
        
        NoticeService::sendRechargeSuccessMsg($data);
    }
    
    private function sendRechargeFailMsg() {
        //充值失败，请在确认打款金额高于最低充值金额1000.00元，且上传的支付截图正确清晰后，重新提交充值申请。（如充值申请金额低于1000.00元，请补齐差额后重新提交充值申请）
        $data = [
            'openid' => 'oYj2y0UqPrYvsTkl1KtYmXBYceXI',
            'first' => '充值失败',
            'money'=>100,
            'time' => date('Y-m-d H:i:s'),
            'account'=> 200,
            'remark' => '请在确认打款金额高于最低充值金额1000.00元，且上传的支付截图正确清晰后，重新提交充值申请。（如充值申请金额低于1000.00元，请补齐差额后重新提交充值申请）',
            'url' => 'http://yiqituan.test.mlilife.com/mobile/index/home.html'
        ];
        
        NoticeService::sendRechargeFailMsg($data);
    }
    
    
    private function sendOrderRewardMsg() {
        $goodsname ='尤妮佳拉拉裤L44男（1包/组）'; 
        $total =100; 
        $reward = 10; 
        $data = [
            'openid' => 'oYj2y0UqPrYvsTkl1KtYmXBYceXI',
            'first' => '直属推荐奖励通知',
            'money'=>$reward,
            'time' => date('Y-m-d H:i:s'),
            'beizhu'=> sprintf('您的直属推荐人购买了%s商品，总价%s元，恭喜您获得%s元直属推荐奖励。',$goodsname,$total,$reward),
            'remark' => '奖励金额已进入您的虚拟币余额，点击前往查看。',
            'url' => 'http://yiqituan.test.mlilife.com/mobile/index/reward_order.html'
        ];
        
        //团队业绩奖励到账通知：您本月的团队业绩返利已到账，总计1234.00元。奖励金额已进入您的虚拟币余额，点击前往查看。
        NoticeService::sendRewardMsg($data);
    }
    
    private function sendTeamRewardMsg() {
        $reward = 10;
        $data = [
            'openid' => 'oYj2y0UqPrYvsTkl1KtYmXBYceXI',
            'first' => '团队业绩奖励到账通知',
            'money'=>$reward,
            'time' => date('Y-m-d H:i:s'),
            'beizhu'=> sprintf('您本月的团队业绩返利已到账，总计%s元。',$reward),
            'remark' => '奖励金额已进入您的虚拟币余额，点击前往查看。',
            'url' => 'http://yiqituan.test.mlilife.com/mobile/index/reward_team.html'
        ];
        
        //团队业绩奖励到账通知：您本月的团队业绩返利已到账，总计1234.00元。奖励金额已进入您的虚拟币余额，点击前往查看。
        NoticeService::sendRewardMsg($data);
    }
    
    
    private function sendLeaderRewardMsg() {
        $reward = 10;
        $month = 8;
        $data = [
            'openid' => 'oYj2y0UqPrYvsTkl1KtYmXBYceXI',
            'first' => '领导积分奖励到账通知',
            'money'=>$reward,
            'time' => date('Y-m-d H:i:s'),
            'beizhu'=> sprintf('您%s月的领导积分返利已到账，总计%s元。',$month,$reward),
            'remark' => '奖励金额已进入您的虚拟币余额，点击前往查看。',
            'url' => 'http://yiqituan.test.mlilife.com/mobile/index/reward_leader.html'
        ];
        
        //领导积分奖励到账通知：您本月的领导积分返利已到账，总计1234.00元。奖励金额已进入您的虚拟币余额，点击前往查看。
        NoticeService::sendRewardMsg($data);
    }
    
    
    private  function sendOrderPayMsg() {
        $goodsname ='尤妮佳拉拉裤L44男（1包/组）'; 
        $money = 10;
        $orderNo =  date('YmdHis');
        $received = '小王';
        $tel = '18612254022';
        $id = 1276;
        $data = [
            'openid' => 'oYj2y0UqPrYvsTkl1KtYmXBYceXI',
            'first' => '订单付款通知',
            'name'=>$goodsname,
            'order_no' => $orderNo,
            'money'=> $money,
            'remark' => sprintf('订单编号：%s已付款。收货人：%s，联系电话：%s，订单金额：%s元。我们将第一时间为您备货，请耐心等待。点击查看订单详情',$orderNo,$received,$tel,$money),
            'url' => sprintf('http://yiqituan.test.mlilife.com//mobile/index/order_detail.html?id=%s',$id),
        ];
        //订单付款通知：订单编号：123456789012345已付款。收货人：XXX，联系电话：18210090518，订单金额：1000.00元。我们将第一时间为您备货，请耐心等待。点击查看订单详情。
        NoticeService::sendOrderPayMsg($data);
    }
    
    private function sendOrderCancelMsg(){
        $money = 10;
        $orderNo =  date('YmdHis');
        $id = 1276;
        $data = [
            'openid' => 'oYj2y0UqPrYvsTkl1KtYmXBYceXI',
            'first' => '订单取消通知',
            'order_no' => $orderNo,
            'money'=> $money,
            'remark' => sprintf('对不起，您的订单编号%s交易失败，已支付的金额将在1小时内返还至您的虚拟币余额。给您带来的不便望请谅解！点击查看订单详情',$orderNo),
            'url' => sprintf('http://yiqituan.test.mlilife.com//mobile/index/order_detail.html?id=%s',$id),
        ];
        //订单驳回通知：对不起，您的订单编号123456789012345交易失败，已支付的金额将在1小时内返还至您的虚拟币余额。给您带来的不便望请谅解！点击查看订单详情。
        NoticeService::sendOrderCancelMsg($data);
        
    }
    
    private function sendOrderFinishMsg(){
        $orderNo =  date('YmdHis');
        $id = 1276;
        $detail = "尤妮佳拉拉裤L44男（1包/组）x 2";
        $data = [
            'openid' => 'oYj2y0UqPrYvsTkl1KtYmXBYceXI',
            'first' => '订单完成通知',
            'order_no' => $orderNo,
            'detail'=> $detail,
            'remark' => sprintf('订单编号：%s已签收。感谢您选择品正，欢迎再次为您服务。点击查看订单详情',$orderNo),
            'url' => sprintf('http://yiqituan.test.mlilife.com//mobile/index/order_detail.html?id=%s',$id),
        ];
        //订单完成通知：订单编号：123456789012345已签收。感谢您选择品正，欢迎再次为您服务。点击查看订单详情。
        NoticeService::sendOrderFinishMsg($data);
    }
    
    private function sendOrderSendMsg(){
        $orderNo =  date('YmdHis');
        $id = 1276;
        $openid = 'oYj2y0UqPrYvsTkl1KtYmXBYceXI';
        $time= date('Y-m-d');
        $address = 'xxxxxxx';
        $remark =  "尤妮佳拉拉裤L44男（1包/组）x 2";
        MsgService::sendOrderDeliveryMsg($openid, $id, $orderNo, $time, $address, $remark);
        
    }
    
    
    private function sendAgentJoinMsg() {
        
        $time =  date('Ymd H:i:s');
        $name = '小李';
        $id = 1276;
        $data = [
            'openid' => 'oYj2y0UqPrYvsTkl1KtYmXBYceXI',
            'first' => sprintf('恭喜您成功推荐的%s成功注册成为品正商，从此开启躺赚模式！',$name),
            'id' => $id,
            'time'=> $time,
            'name'=> $name,
            'remark' => '',
            'url' => '',
        ];
        //恭喜您成功推荐的XX成功注册成为品正商，从此开启躺赚模式！
        NoticeService::sendAgentJoinMsg($data);
    }
    
    private function sendLevelChangeMsg() {
        $time =  date('Y-m-d H:i:s');
        $data = [
            'openid' => 'oYj2y0UqPrYvsTkl1KtYmXBYceXI',
            'first' => '恭喜您完成品正商招募任务，成功晋升为品正商V！每月可获得额外的领导积分奖励！',
            'time'=> $time,
            'remark' => '',
            'url' => 'http://yiqituan.test.mlilife.com/mobile/index/reward_leader.html',
        ];
        //恭喜您成功推荐的XX成功注册成为品正商，从此开启躺赚模式！
        NoticeService::sendLevelChangeMsg($data);
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}